package com.centaline.invoke.server.impl;

import com.centaline.invoke.httpClient.HttpAPIService;
import com.centaline.invoke.service.TeleiiGateway;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created by caoyuan7 on 2018/2/1.
 */
@Service
public class TeleiiGatewayImpl implements TeleiiGateway {
    @Resource
    private HttpAPIService httpAPIService;

    @Value("${teleii.client.host.url}")
    private String teleiiHost;
    /**
     * 这里请求teleii的接口，只返回数据不处理业务
     * 这里定义的方法，需要到conf下的HttpInvokerExporterConfiguraion.java中注册一下
     * @author caoy
     * @return
     * @throws Exception
     */
    public String test() throws Exception {
        HttpResponse str = httpAPIService.doGet(teleiiHost+"demo");
        String conResult = EntityUtils.toString(str.getEntity());
        return conResult;
    }

}
